package de.hundezimmer.ui;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Vector;

import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.VerticalLayout;

import de.hundezimmer.beans.Dog;
import de.hundezimmer.db.DBDog;

public class showDogs extends VerticalLayout {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1564397875985722611L;
	private DBDog dbConnection;

	public showDogs(Connection conn) {

		dbConnection = new DBDog(conn);

		final NativeSelect select = new NativeSelect("Hunde");

		Vector<Dog> dogs;
		try {
			dogs = dbConnection.getAllDogs();

			for (Dog d : dogs) {
				select.addItem(d.getName());
			}

			select.setNullSelectionAllowed(false);

			this.addComponent(select);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
